

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

import '../../../sample/configure/constants.dart';
import '../../../theme.dart';
import '../../event/event.dart';
import '../local_replay.dart';

class LiveBottomEntryWidget extends StatelessWidget {
  final String deviceId;
  final String deviceName;

  const LiveBottomEntryWidget({
    super.key,
    required this.deviceId,
    required this.deviceName,
  });

  @override
  Widget build(BuildContext context) {
    return Column(
      children: <Widget>[
        // _buildItem(
        //   icon: Icons.event_note_rounded,
        //   iconColor: Colors.white,
        //   iconBackgroundColor: SampleThemeConfigure.colorPrimary,
        //   mainTitle: '告警',
        //   subTitle: '拍摄到的重要事件',
        //   onTap: () {
        //     Navigator.push(
        //       context,
        //       MaterialPageRoute(
        //         builder: (context) => EventPage(
        //           deviceId: deviceId,
        //         ),
        //       ),
        //     );
        //   },
        // ),
        if (SampleConstants.fullAbilitiesMode)
          _buildItem(
            icon: Icons.sd_card_rounded,
            iconColor: Colors.white,
            iconBackgroundColor: Colors.green,
            mainTitle: '卡录像',
            subTitle: '播放SD卡的录像',
            onTap: () {
              Navigator.push(
                context,
                MaterialPageRoute(
                  builder: (context) => LocalReplayPage(deviceId: deviceId, deviceName: "1"),
                ),
              );
            },
          ),
        // if (SampleConstants.fullAbilitiesMode)
        //   _buildItem(
        //     icon: Icons.cloud,
        //     iconColor: Colors.white,
        //     iconBackgroundColor: const Color.fromRGBO(162, 54, 244, 0.689),
        //     mainTitle: '云录像',
        //     subTitle: '播放云端的录像',
        //     onTap: () {
        //       // 处理点击事件
        //     },
        //   ),
      ],
    );
  }

  Widget _buildItem({
    required IconData icon,
    required Color iconColor,
    required Color iconBackgroundColor,
    required String mainTitle,
    required String subTitle,
    required VoidCallback onTap,
  }) {
    return ListTile(
      contentPadding: const EdgeInsets.only(left: 16, right: 16, top: 16),
      leading: CircleAvatar(
        radius: 20.0,
        backgroundColor: iconBackgroundColor,
        child: Icon(
          icon,
          color: iconColor,
          size: 18,
        ),
      ),
      title: Text(mainTitle, style: const TextStyle(fontWeight: FontWeight.bold, fontSize: 14, color: SampleThemeConfigure.colorTextPrimary)),
      subtitle: Text(subTitle, style: const TextStyle(fontSize: 12, color: SampleThemeConfigure.colorTextHint)),
      trailing: const Icon(
        Icons.arrow_forward_ios,
        color: Color.fromARGB(173, 158, 158, 158),
        size: 12,
      ),
      onTap: onTap,
    );
  }
}
